package com.imooc.utils;

import com.imooc.enums.CodeEnum;

/**
 * @author Create By Liuqz
 * @date 2018/6/7 17:43
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getEnum(Integer code,Class<T> enumClass){
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())){
                return each;
            }
        }

        return null;
    }
}
